package com.bigwork.service.impl;

//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bigwork.dto.product.ProductDto;
import com.bigwork.entity.Product;
import com.bigwork.mapper.ProductMapper;
import com.bigwork.service.ProductService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class ProductServiceImpl implements ProductService {

    private final ProductMapper productMapper;

    @Override
    public Product addProduct(ProductDto productDto) {
        Product product = new Product();
        product.setName(productDto.getName());
        product.setDescription(productDto.getDescription());
        product.setPrice(productDto.getPrice());
        product.setCategory(productDto.getCategory());
        productMapper.insert(product);
        return product;
    }

    @Override
    public List<Product> searchProductsByName(String name) {
        return productMapper.selectByName(name);
    }

    @Override
    public List<Product> searchProductsByCategory(String category) {
        return productMapper.selectByCategory(category);
    }

    @Override
    public List<Product> getAllProducts() {
        return productMapper.selectAll();
    }
}